package com.richest.api.controller.cn.client.score;

import java.util.*;

import com.richest.api.service.IEatOrderScoreService;
import com.richest.bean.EatOrderScoreBean;
import com.richest.util.CallResults;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import java_cup.runtime.virtual_parse_stack;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.web.bind.annotation.*;

/**
 * 就餐订单评分接口
 * 
 * @author zhaohongchao
 * @email 70375739@qq.com
 * @date 2019-02-28 14:15:26
 */
@RestController
@RequestMapping("eatOrderScoreController")
@Api(value = "就餐订单评分接口")
@EnableAutoConfiguration
public class ApiEatOrderScoreController {
	@Autowired
	private IEatOrderScoreService eatOrderScoreService;

	/**
	 * 保存评价
	 * 
	 * @author zhaohongchao 2019年4月2日 下午1:26:39
	 * @email 70375739@qq.com
	 * @param form
	 * @return
	 */
	@RequestMapping(value = "saveEatOrderScore", produces = "application/json;charset=UTF-8")
	@ApiOperation(notes = "保存评价", value = "保存评价", httpMethod = "POST")
	@ApiImplicitParam(name = "eatOrderScoreBean", value = "评价内容表单", required = true, dataType = "EatOrderScoreBean")
	public CallResults saveEatOrderScore(@RequestBody EatOrderScoreBean eatOrderScoreBean) {
		eatOrderScoreBean.setStatus(1);
		eatOrderScoreBean.setStatus_name("正常");
		eatOrderScoreBean.setType(1);
		eatOrderScoreBean.setCreate_time(new Date());
		eatOrderScoreService.saveEatOrderScore(eatOrderScoreBean);
		return CallResults.ok();
	}

	/**
	 * 获取店铺评分
	 * 
	 * @author zhaohongchao 2019年4月2日 下午1:45:28
	 * @email 70375739@qq.com
	 * @param admart_id
	 * @return
	 */
	@RequestMapping(value = "getScore", produces = "application/json;charset=UTF-8")
	@ApiOperation(notes = "获取店铺评分", value = "获取店铺评分", httpMethod = "GET")
	@ApiImplicitParam(name = "admart_id", value = "店铺id", required = true, paramType = "query", dataType = "Long")
	public CallResults getScore(@RequestParam Long admart_id) {

		return CallResults.ok().put("data", eatOrderScoreService.getScore(admart_id));
	}
}
